package org.ajax.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author ZQX
 * @date 2024-11-18
 */
@WebServlet("/hello.do")
public class HelloAjaxServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // service - dao ...
        String msg = "hello,ajax" ;
        // 把数据转换为 JSON 字符串（略）
        // 把数据以流的方式输出到客户端浏览器中
        PrintWriter out = resp.getWriter();
        out.write(msg);

        out.flush();
        out.close();

    }
}
